package com.digitaldreamers.spaceshooter.effect;

import org.andengine.entity.Entity;
import org.andengine.entity.IEntity;
import org.andengine.entity.particle.Particle;
import org.andengine.entity.particle.modifier.ScaleParticleModifier;
import org.andengine.util.modifier.ease.EaseLinear;
import org.andengine.util.modifier.ease.IEaseFunction;

public class MyScaleParticleModifier<T extends IEntity> extends ScaleParticleModifier<T> {
	private float mParticleScaleCenterX;
	private float mParticleScaleCenterY;
	
	public MyScaleParticleModifier(final float pFromTime, final float pToTime, final float pFromScale, final float pToScale) {
		this(pFromTime, pToTime, pFromScale, pToScale, EaseLinear.getInstance());
	}

	public MyScaleParticleModifier(final float pFromTime, final float pToTime, final float pFromScale, final float pToScale, final IEaseFunction pEaseFunction) {
		this(pFromTime, pToTime, pFromScale, pToScale, pFromScale, pToScale, pEaseFunction);
	}

	public MyScaleParticleModifier(final float pFromTime, final float pToTime, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY) {
		this(pFromTime, pToTime, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, EaseLinear.getInstance());
	}

	public MyScaleParticleModifier(final float pFromTime, final float pToTime, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY, final IEaseFunction pEaseFunction) {
		super(pFromTime, pToTime, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, pEaseFunction);
		this.mParticleScaleCenterX = Entity.SCALE_CENTER_X_DEFAULT;
		this.mParticleScaleCenterY = Entity.SCALE_CENTER_Y_DEFAULT;
	}
	
	public void setParticleScaleCenterX(float pScaleCenterX) {
		this.mParticleScaleCenterX = pScaleCenterX;
	}
	
	public void setParticleScaleCenterY(float pScaleCenterY) {
		this.mParticleScaleCenterY = pScaleCenterY;
	}
	
	public void setParticleScaleCenter(float pScaleCenterX, float pScaleCenterY) {
		this.mParticleScaleCenterX = pScaleCenterX;
		this.mParticleScaleCenterY = pScaleCenterY;
	}
	
	@Override
	protected void onSetInitialValues(final Particle<T> pParticle, final float pScaleX, final float pScaleY) {
		pParticle.getEntity().setScaleCenter(this.mParticleScaleCenterX, this.mParticleScaleCenterY);
		super.onSetInitialValues(pParticle, pScaleX, pScaleY);
	}
}
